package com.ken.astroboy.quartz;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.ken.astroboy.core.InMemoryStorage;
import com.ken.astroboy.logic.LogicProcess;
import com.ken.astroboy.model.Contact;
import com.ken.astroboy.model.ScheduledTaskCustomData;
import com.ken.astroboy.service.WxService;

public class SyncGroupInfoJob extends AbstractJob{

	@Override
	void doJob(ScheduledTaskCustomData customData) throws IOException {
		
		List<Contact> list = new ArrayList<>();
		
		for(Map.Entry<String, Contact> entry : InMemoryStorage.groupMap.entrySet()){
			
			if(InMemoryStorage.userGroupCtrlEntity.getGroupList().contains(entry.getKey())){
				list.add(entry.getValue());
			}	
		}
		
		LogicProcess.handleBatchGetContactResponse( WxService.getBatchContact( list, true ) );

	}
}
